﻿using System;

public static class EntityFactory
{
    public static T Create<T>(this Entity self) where T : Entity    
    {
        var instance = Activator.CreateInstance(typeof(T)) as T;
        instance.Parent = self;
        (instance as IAwake)?.Awake();
        return instance;
    }

    public static T Create<T, A>(this Entity self, A a) where T : Entity
    {
        var instance = Activator.CreateInstance(typeof(T)) as T;
        instance.Parent = self;
        (instance as IAwake<A>)?.Awake(a);
        return instance;
    }

    public static T Create<T, A, A1>(this Entity self, A a, A1 a1) where T : Entity
    {
        var instance = Activator.CreateInstance(typeof(T)) as T;
        instance.Parent = self;
        (instance as IAwake<A, A1>)?.Awake(a, a1);
        return instance;
    }
    public static T Create<T, A, A1, A2>(this Entity self, A a, A1 a1, A2 a2) where T : Entity
    {
        var instance = Activator.CreateInstance(typeof(T)) as T;
        instance.Parent = self;
        (instance as IAwake<A, A1, A2>)?.Awake(a, a1, a2);
        return instance as T;
    }

}
